package com.daniel.memo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

//CREATE TABLE Task (taskId INTEGER PRIMARY KEY AUTOINCREMENT, memoId INTEGER, 
//todoId INTEGER, aramDateTime DATETIME, isAramOn BOOL, priority INTEGER, isCompleted BOOL);
public class Task extends Memo {

	public static final String TASK_TABLE_NAME = "Task";
	public static final String TASK_ID = "taskId"; 
	public static final String MEMO_ID = "memoId";
	public static final String TODO_ID = "todoId";
	public static final String ARAM_TIME_DATE = "aramDateTime";
	public static final String IS_ARAM_ON = "isAramOn";
	public static final String PRIORITY = "priority";
	public static final String IS_COMPLETED = "isCompleted";
	
	public static final int HIGH = 1;
	public static final int MEDIUM = 2; 
	public static final int LOW = 3;
	
	public static final String TASK_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm";
		
	private int taskId;
	private int memoId;
	private int todoId;
	private Calendar aramDateTime;
	private boolean isAramOn;
	private int priority;
	private boolean isCompleted;
	
	private boolean isSelectedForDel;
	
	public Task(int taskId, int memoId, int j) {
		
	}
	
	public Task(String title, String memo, int taskId, int memoId, int priority, String notiDate, 
			boolean isAramOn, boolean isCompleted) {
		
		setTitle(title);
		setMemo(memo);
		
		this.taskId = taskId;
		this.memoId = memoId;
		this.priority = priority;
		
		Date date = covertStrToDate(notiDate, TASK_DATE_TIME_FORMAT);
		aramDateTime = Calendar.getInstance();
		aramDateTime.setTime(date);
		
		this.isAramOn = isAramOn;
		this.isCompleted = isCompleted;
	}
	
	public int getTaskId() {
		return this.taskId;
	}
	public void setTaskId(int taskId) {
		this.taskId = taskId;
	}
	
	public boolean getIsCompleted() {
		return this.isCompleted;
	}
	public void setIsCompleted(boolean isCompleted) {
		this.isCompleted = isCompleted;
	}
	
	/*
	public void switchIsCompleted() {
		if (this.isCompleted == true) {
			this.isCompleted = false;
		} else {
			this.isCompleted = true;
		}
	}
	*/
	
	public boolean getIsAramOn() {
		return this.isAramOn;
	}
	public void setIsAramOn(boolean isAramOn) {
		this.isAramOn = isAramOn;
	}
	
	public void setIsSelectedForDel(boolean isSelectedForDel) {
		this.isSelectedForDel = isSelectedForDel;
	}
	public boolean getIsSelectedForDel() {
		return this.isSelectedForDel; 
	}
	
	public Date covertStrToDate(String dateString, String DateFormat){
		Date converteDate = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(DateFormat);
		
		try  {
			converteDate = dateFormat.parse(dateString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return converteDate;
	}
	
	public String getStrNotiDate() {
		String strDate;
		SimpleDateFormat dateFormat = new SimpleDateFormat(TASK_DATE_TIME_FORMAT);
		
		strDate = dateFormat.format(aramDateTime.getTime());
		
		return strDate;
	}
	
}
